package com.web.dao;

import com.web.entity.Permission;
import com.web.entity.PermissionExample;
import java.util.List;

import com.web.entity.SysMenu;
import com.web.utils.mybatis.SimpleSelectInLangDriver;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

/**
 * @author FDjavaone
 */
public interface PermissionMapper {
    @SelectProvider(type=PermissionSqlProvider.class, method="countByExample")
    int countByExample(PermissionExample example);

    @DeleteProvider(type=PermissionSqlProvider.class, method="deleteByExample")
    int deleteByExample(PermissionExample example);

    @Delete({
        "delete from t_permission",
        " where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into t_permission (text, perm,",
        " menu_id, type, url, ",
        " description)",
        " values (#{text,jdbcType=VARCHAR}, #{perm,jdbcType=VARCHAR}, ",
        " #{menuId,jdbcType=BIGINT}, #{type,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR}, ",
        " #{description,jdbcType=VARCHAR})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insert(Permission record);

    @InsertProvider(type=PermissionSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insertSelective(Permission record);

    @SelectProvider(type=PermissionSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="text", property="text", jdbcType=JdbcType.VARCHAR),
        @Result(column="perm", property="perm", jdbcType=JdbcType.VARCHAR),
        @Result(column="menu_id", property="menuId", jdbcType=JdbcType.BIGINT),
        @Result(column="type", property="type", jdbcType=JdbcType.VARCHAR),
        @Result(column="url", property="url", jdbcType=JdbcType.VARCHAR),
        @Result(column="description", property="description", jdbcType=JdbcType.VARCHAR)
    })
    List<Permission> selectByExample(PermissionExample example);

    @Select({
        "select",
        " id, text, perm, menu_id, type, url, description",
        " from t_permission",
        " where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="text", property="text", jdbcType=JdbcType.VARCHAR),
        @Result(column="perm", property="perm", jdbcType=JdbcType.VARCHAR),
        @Result(column="menu_id", property="menuId", jdbcType=JdbcType.BIGINT),
        @Result(column="type", property="type", jdbcType=JdbcType.VARCHAR),
        @Result(column="url", property="url", jdbcType=JdbcType.VARCHAR),
        @Result(column="description", property="description", jdbcType=JdbcType.VARCHAR)
    })
    Permission selectByPrimaryKey(Long id);

    @UpdateProvider(type=PermissionSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Permission record, @Param("example") PermissionExample example);

    @UpdateProvider(type=PermissionSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Permission record, @Param("example") PermissionExample example);

    @UpdateProvider(type=PermissionSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Permission record);

    @Update({
        "update t_permission",
        " set text = #{text,jdbcType=VARCHAR},",
          " perm = #{perm,jdbcType=VARCHAR},",
          " menu_id = #{menuId,jdbcType=BIGINT},",
          " type = #{type,jdbcType=VARCHAR},",
          " url = #{url,jdbcType=VARCHAR},",
          " description = #{description,jdbcType=VARCHAR}",
        " where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(Permission record);


    @Select("select * from t_permission where id in(#{ids})")
    @Lang(SimpleSelectInLangDriver.class)
    List<Permission> selectInId(@Param("ids") List<Long> ids);
}